#@layout()

#define css()
<style>
    table a {
        color: #007bff;
    }
</style>

#end
#define script()
<script>

    function complete(taskId,action){
        console.log("complete....",action)

        if (action == 'stop'){
            stop(taskId);
            return
        }

        var btnText = "";
        if (action == "agree"){
            btnText = "确定同意"
        }else if (action == "refuse"){
            btnText = "确定拒绝"
        }else if (action == "rebut"){
            btnText = "确定驳回"
        }


        layer.prompt({title: '请填写审批意见', formType: 2, btn:[btnText,'取消'],offset:'20%'}, function(comment, index){
            layer.close(index);
            var data = {
                taskId:taskId,
                action:action,
                comment:comment
            }
            ajaxPost("#(CPATH)/admin/flow/complete",data,function (){
                location.reload();
            })
        });

    }

    function stop(taskId){
        console.log("stop....")

        layer.prompt({title: '请填写终止原因', formType: 2,btn:['终止流程','取消'],offset:'20%'}, function(comment, index){
            layer.close(index);
            var data = {
                taskId:taskId,
                action:'stop',
                comment:comment
            }
            ajaxPost("#(CPATH)/admin/flow/stop",data,function (){
                location.reload();
            })
        });
    }



</script>
#end

#define content()
    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                我的待办
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 审核 / 我的待办</small>
                            </h1>
                        </div>
                    </div>
                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>


    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-header with-border">

                    </div>
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 100px">
                                    ID
                                </th>
                                <th style="width: 30%">待办事项</th>
                                <th>相关内容</th>
                                <th>上级意见</th>
                                <th style="width: 150px">发布时间</th>
<!--                                <th width="200px">操作</th>-->
                            </tr>
                            #for(item : page.list)
                            <tr>
                                <td>
                                    #(item.taskId ??)
                                </td>
                                <td>
                                    <strong>
                                        #(item.name ??)
                                    </strong>
                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            #for(action : item.actions)
                                            <a href="javascript:;"  class="#(action.value == 'stop' ? 'red-action' : '')" onclick="complete('#(item.taskId ??)','#(action.value ??)')">
                                                #(action.text ??)
                                            </a> |
                                            #end
                                            <a href="#(CPATH)/admin/flow/processDetail?taskId=#(item.taskId ??)"
                                               open-type="layer" data-layer-title="查看任务进度">任务进度</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                     #(item.contentTitle ??) （<a href="#(CPATH)/admin/flow/todoDetail?taskId=#(item.taskId ??)"
                                                                 open-type="layer" data-layer-title="内容详情">详情</a>）
                                </td>
                                <td>#(item.comment ??)</td>
                                <td>#date(item.created ??)</td>
                            </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-6">
                            </div>

                            <div class="col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div>
    </section>
#end
